﻿<!--#include Virtual="../config.asp"-->
<!--#include Virtual="/public_sub.asp"-->
<%
var newsid = t_cint(request("newsid")),
cachepath = "/cache/newscontent/"+newsid%100+"/"+newsid;

Server.ScriptTimeout = 9999999;

if(request("all")!=""){
	//找到下一条
	Rs = ExecSql("select top 1 id from news_content where id>"+newsid+" order by id asc");
	if(!Rs.Eof || !Rs.Bof){
		Write('<meta http-equiv="refresh" content="0; url=?newsid='+t_cint(Rs(0))+'&all=1">');
	}else{
		Write('已全部更新完毕');
	}
}

Rs = ExecSql("select news_content from news_content where id="+newsid+"");
if(Rs.Eof && Rs.Bof) WriteErr("",404);
content = Rs2Json(Rs)[0].news_content;

CloseRs();
CloseConn();

if(content.indexOf('id="p" name="p"')!=-1){
	var pagecontents = content.split('<a class="newspage" id="p" name="p">');//将内容切割为数组，元素0为空，元素n为第n页内容
	var allcontent = "";
	foreach(pagecontents,function(i,v){//分页内容
		if(i==0) return true;
		v = replaceKeyLink(v);
		var cachetxt = '<a class="newspage" id="p'+i+'" name="p'+i+'">第'+i+'页：'+v;
		var cachefile = cachepath+"_"+i+".txt";
		AdoWriteFile(cachefile,cachetxt);
		allcontent += cachetxt;
	});
	AdoWriteFile(cachepath+".txt",allcontent);//全部内容
}else{
	AdoWriteFile(cachepath+".txt",replaceKeyLink(content));//无分页
}
Write(newsid+"缓存更新成功！");
%>